<?php

/**
 * This is the model class for table "material".
 *
 * The followings are the available columns in table 'material':
 * @property integer $materialid
 * @property string $materialname
 * @property integer $storagequantity
 * @property integer $unitid
 * @property integer $materialmilit
 */
class Material extends MaterialBase
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Material the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	
	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
                    'unit' => array(self::BELONGS_TO, 'Unit', 'unitid')
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'materialid' => 'Material ID',
			'materialname' => 'Material Name',
			'storagequantity' => 'Storage Quantity',
			'unitid' => 'Unit',
			'materialmilit' => 'Materia Milit',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('materialid',$this->materialid);
		$criteria->compare('materialname',$this->materialname,true);
		$criteria->compare('storagequantity',$this->storagequantity);
		$criteria->compare('unitid',$this->unitid);
		$criteria->compare('materialmilit',$this->materialmilit);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}